﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }     
    private void button1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.graphics = form2.CreateGraphics();
            form2.per1 = Convert.ToDouble(this.Textbox_per1.Text);
            form2.per2 = Convert.ToDouble(this.Textbox_per2.Text);
            form2.n = Convert.ToInt32(this.Textbox_n.Text);
            form2.th1 = Convert.ToInt32(this.Textbox_th1.Text) * Math.PI / 180;
            form2.th2 = Convert.ToInt32(this.Textbox_th2.Text) * Math.PI / 180;
            form2.length = Convert.ToInt32(this.textBox1.Text);
            int Red = this.trackBar1.Value;
            int Green = this.trackBar2.Value;
            int Blue = this.trackBar3.Value;
            form2.pen = new Pen(Color.FromArgb(Red, Green, Blue));
            form2.ShowDialog();
            
        }
        private Graphics graphics;

        private void trackBar_ValueChanged(object sender, EventArgs e)
        {
            int Red = this.trackBar1.Value;
            int Green = this.trackBar2.Value;
            int Blue = this.trackBar3.Value;
            if (graphics == null)
                graphics = this.CreateGraphics();
            graphics.FillRectangle(new SolidBrush(Color.FromArgb(Red, Green, Blue)), 410, 280, 100, 50);

        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            label.Text = $"({e.X},{e.Y})";
        }



        //private void Form1_Load(object sender, EventArgs e)
        //{
        //    if (graphics == null)
        //        graphics = this.CreateGraphics();

        //    int Red = Convert.ToInt32(this.red.Text);
        //    int Green = Convert.ToInt32(this.green.Text);
        //    int Blue = Convert.ToInt32(this.blue.Text);

        //    //graphics.DrawRectangle(new Pen(Color.FromArgb(Red, Green, Blue)), 410, 280, 100, 50);
        //    graphics.FillRectangle(new SolidBrush(Color.FromArgb(Red, Green, Blue)), 410, 280, 100, 50);
        //}
    }
}